﻿using QQExpression.Utils.Currency;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QQExpression.Utils
{
    class ImageHelper
    {

        public void DeleteLittleImageFloder(string FloderPath, int MinWidth, int MinHeight) {

            foreach (string line in FloderHelper.GetFullFileNameList(FloderPath)) {

                DeleteLittleSinleImage(line,MinWidth,MinHeight);
            }
        }
        /// <summary>
        /// 删除缩略图，指定小于等于某个宽高即处理
        /// </summary>
        /// <param name="FilePath"></param>
        /// <param name="MinWidget"></param>
        /// <param name="MinHeight"></param>
        public void DeleteLittleSinleImage(string FilePath, int MinWidth, int MinHeight)
        {
            try
            {

                using (System.Drawing.Image localimage = System.Drawing.Image.FromFile(FilePath)) {

                    Console.WriteLine("图片{0}，Width：{1}  Height{2}", FileHelper.GetFileName(FilePath), localimage.Width, localimage.Height);
                    if (localimage.Width > MinWidth && localimage.Height > MinHeight)
                    {

                        return;
                    }
                }
            
                Console.WriteLine("不符合规定，删除");
                FileHelper.FileDelete(FilePath);

            }
            catch (Exception ex)
            {
                PrintLog.Log(ex);
                PrintLog.Log(FilePath);
            }
        }
    }
}
